import papers from '../../apis/papers';

export default {
  namespaced: true,
  state: {
    loading: false,
    papers: [],
    count: 0,
  },
  mutations: {
    setLoading(state, data) {
      state.loading = data;
    },
    setPapers(state, data) {
      state.papers = data;
    },
    setCount(state, data) {
      state.count = data;
    },
  },
  actions: {
    async getPapers({ commit }, data) {
      commit('setLoading', true);
      const { data: { result, count } } = await papers.getPapers(data);
      commit('setPapers', result);
      commit('setCount', count);
      commit('setLoading', false);
    },
  },
};
